package People;

import java.util.ArrayList;

/**
 * Models an individual of simulation
 * 
 * @author Amir BEN SLIMANE
 */
public class People {
	protected Status status;
	protected Sexe sexe;
	protected int infectionRate;
	protected ArrayList<Status> healthRecord;

	/**
	 * Builder's People
	 * 
	 * @param status
	 */
	public People(Status status) {
		this.status = status;
		this.healthRecord = new ArrayList<>();
	}

		
	/**
	 * @return the status
	 */
	public Status getStatus() {
		return status;
	}


	/**
	 * @param status the status to set
	 */
	public void setStatus(Status status) {
		this.status = status;
	}


	/**
	 * @return the sexe
	 */
	public Sexe getSexe() {
		return sexe;
	}


	/**
	 * @param sexe the sexe to set
	 */
	public void setSexe(Sexe sexe) {
		this.sexe = sexe;
	}



	/**
	 * @return the infectionRate
	 */
	public int getInfectionRate() {
		return infectionRate;
	}


	/**
	 * @param infectionRate the infectionRate to set
	 */
	public void setInfectionRate(int infectionRate) {
		this.infectionRate = infectionRate;
	}

	/**
	 * @return the healthRecord
	 */
	public ArrayList<Status> getHealthRecord() {
		return healthRecord;
	}


	/**
	 * @param healthRecord the healthRecord to set
	 */
	public void setHealthRecord(ArrayList<Status> healthRecord) {
		this.healthRecord = healthRecord;
	}

	/**
	 * Add a status to healthRecord
	 */
	public void addStatus(){
		this.healthRecord.add(this.getStatus());
	}

	/**
	 * Returns random sexe of People
	 *  
	 * @return Sexe
	 */
	public Sexe sexeRandom() {
		if ((int) Math.random() * 2 == 1) {
			return Sexe.Female;
		} else {
			return Sexe.Male;
		}
	}
	
	public People clone() {
		People people = new People(this.status);
		people.setSexe(this.sexe);
		people.setInfectionRate(this.infectionRate);
		return people;
	}
	
	public void copyFrom(People people) {
		this.setInfectionRate(people.getInfectionRate());
		this.setSexe(people.getSexe());
		this.setStatus(people.getStatus());
		this.setHealthRecord(people.getHealthRecord());
	}
	
	public void switchPeople(People people1, People people2) {
		People peopleTemp = people1.clone();
		people1.copyFrom(people2);
		people2.copyFrom(peopleTemp);
	}

	public String toString() {
		switch (this.status) {
		case Contagious:
			return "C";
		case Dead:
			return "X";
		case Empty:
			return " ";
		case Healthy:
			return "H";
		case Recovering:
			return "R";
		case Sick:
			return "S";
		default:
			return " ";
		}
	}
}
